<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="ct" uri="/WEB-INF/tags/tag.tld" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>List all students of system</title>
</head>
<body>
	<c:if test="${!empty students}">
	<table border="1">
		<c:forEach items="${students}" var="s">
		<tr>
			<td><c:out value="${s.studentId}" /></td>
			<td><c:out value="${s.studentName}" /></td>
			<td><c:out value="${s.studentAge}" /></td>
			<c:choose>
				<c:when test="${s.instructor != null}">
					<td><c:out value="${s.instructor.instructorName}" /></td>
				</c:when>
				<c:otherwise>
					<td><c:out value="" /></td>
				</c:otherwise>
			</c:choose>
			<td>
				<ul>
					<c:forEach items="${s.uploadedFiles}" var="f">
						<li><c:out value="${f.fileName}" /></li>
						<li><c:out value="${f.student.studentName}" /></li>
						<ct:keyToString var="url" key="${f.key}"/>
						<li><a href="/uploadedFile/delete/${url}">Delete file</a></li>
					</c:forEach>
				</ul>
			</td>
			<ct:keyToString var="url" key="${s.key}"/>
			<td><a href="/students/getClassesOfStudent/${url}">Click here for registering class for student</a></td>
			<td><a href="/students/assignInstructor/${url}">Add instructor</a></td>
			<td><a href="/students/upload/${url}">Add file</a></td>
			<td><a href="/students/delete/${url}">Delete student</a></td>
		</tr>
		</c:forEach>
	</table>
	</c:if>
</body>
</html>